package com.project.gcsj5.controller;

import com.project.gcsj5.common.Result;
import com.project.gcsj5.model.Booklist;
import com.project.gcsj5.service.BooklistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
public class BooklistController {
    @Autowired
    private BooklistService service;

    @GetMapping("/booklist/{re_id}")
    public Result Getlist(@PathVariable int re_id){
        List<Booklist> s = new ArrayList<>();
        s=service.find_re_id(re_id);
        if(s!=null)
        {return  Result.success(s);}
        else
        {return Result.fail();}
    }

    @PostMapping("/booklist")
    public Result save (@RequestBody List<Booklist> booklists){
        int a =service.insert_many(booklists);
        if(a!=0)
        {return Result.success(a);}
        else
        {return Result.fail();}
    }
}
